package com.chinasofti.udp;

import java.io.IOException;
import java.net.*;

public class SendDemo {
    public static void main(String[] args) throws IOException {
        //创建发送端Socket对象
        DatagramSocket ds = new DatagramSocket();
        //创建数据
        byte[] bys = "hello,upd".getBytes();
        DatagramPacket dp = new DatagramPacket( bys, bys.length, InetAddress.getByName("127.0.0.1"),10086);
        //调用DatagramSocket send(DatagramPacket p)
        ds.send(dp);//从套接发送数据包
        //关闭发送端
        ds.close();
    }
}
